package com.ruoyi.merchant.service.impl;

import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.merchant.domain.PmsSkuInfo;
import com.ruoyi.merchant.mapper.MerchantMapper;
import com.ruoyi.merchant.mapper.PmsCouponMapper;
import com.ruoyi.merchant.service.MerchantService;
import com.ruoyi.system.common.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 28173
 * #Description MerchantService
 * #Date: 2025/1/13 22:01
 */
@Service
public class MerchantServiceImpl implements MerchantService {
    @Autowired
    private TokenService tokenService;
    @Autowired
    private PmsCouponMapper pmsCouponMapper;
    @Autowired
    private MerchantMapper merchantMapper;
    /**
     * 商家所拥有的商品列表
     * @return
     */
    @Override
    public List<PmsSkuInfo> productList() {
        LoginUser loginUser = tokenService.getLoginUser();
        Long merchantId = pmsCouponMapper.GetPmsMerchantCouponByUserId(loginUser.getUserid());
        List<PmsSkuInfo> pmsSkuInfoList = merchantMapper.productList(merchantId);
        return pmsSkuInfoList;
    }

    @Override
    public List<PmsSkuInfo> getProductList(Long[] ids) {
        LoginUser loginUser = tokenService.getLoginUser();
        Long merchantId = pmsCouponMapper.GetPmsMerchantCouponByUserId(loginUser.getUserid());
        List<PmsSkuInfo> pmsSkuInfoList = merchantMapper.getProductList(merchantId,ids);
        return pmsSkuInfoList;
    }
}
